package com.explorati.design_pattern.creational.prototype.clone.example;

import java.text.MessageFormat;
import java.util.Date;
import java.util.Random;

public class MailUtils {

	public static String getRandString(int len) {
		String source = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ";
		Random random = new Random();
		String s = "";

		for (int i = 0; i < len; i++) {
			s += source.charAt(random.nextInt(source.length()));
		}
		return s;
	}

	public static void sendMail(Mail mail, Date date) {
		mail.setDate(date);
		String outputContent = "标题 : {0} \t 收件人 : {1} \t  日期：{2} \t... 发送成功";
		System.out.println(MessageFormat.format(outputContent, mail.getSubject(), mail.getReceiver(), mail.getDate()));
	}
}
